package com.h2cloud;

import lombok.Data;
import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @Package: com.h2cloud
 * @ClassName: stream
 * @Author: wulongkai
 * @CreateTime: 2023/8/10 19:29
 * @Description:
 */
public class stream {
    public static void main(String[] args) {
        List<Person> psList = new ArrayList<>();
        Person p = new Person();
        p.setAge(12);
        p.setName("13");
        psList.add(p);
        Map<Integer, Person> collect = psList.stream().collect(Collectors.toMap(Person::getAge, o -> o));
        for (Map.Entry<Integer, Person> integerPersonEntry : collect.entrySet()) {
            integerPersonEntry.getValue().setName("longaki");
        }
        System.out.println(p);
    }
}
@Data
@Getter
@Setter
class Person {
    int age;
    String name;
}
